using System;
using NUnit.Framework;

namespace AndyPike.Commons.Tests.Unit
{
    [TestFixture]
    public class When_guarding_against_arguments
    {
        [Test]
        public void Should_not_throw_an_exception_with_a_valid_string()
        {
            GuardAgainst.ArgumentNullOrEmpty("this is a string", "string");
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Should_throw_an_exception_with_a_null_string()
        {
            GuardAgainst.ArgumentNullOrEmpty(null, "string");
        }

        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void Should_throw_an_exception_with_an_empty_string()
        {
            GuardAgainst.ArgumentNullOrEmpty(string.Empty, "string");
        }

        [Test]
        public void Should_not_throw_an_exception_with_a_valid_integer()
        {
            GuardAgainst.ArgumentOutsideRange(5, "number", 1, 10);
        }

        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void Should_throw_an_exception_with_an_integer_that_is_too_small()
        {
            GuardAgainst.ArgumentOutsideRange(0, "number", 1, 10);
        }

        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void Should_throw_an_exception_with_an_integer_that_is_too_large()
        {
            GuardAgainst.ArgumentOutsideRange(11, "number", 1, 10);
        }

        [Test]
        public void Should_not_throw_an_exception_with_an_instantiated_argument()
        {
            GuardAgainst.ArgumentNull(new String(new char[] {}), "string");
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Should_throw_an_exception_with_a_null_argument()
        {
            GuardAgainst.ArgumentNull(null, "project");
        }

        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void Should_throw_an_exception_with_an_empty_guid()
        {
            GuardAgainst.ArgumentEmpty(Guid.Empty, "guid");
        }

        [Test]
        public void Should_not_throw_an_exception_with_a_valid_guid()
        {
            GuardAgainst.ArgumentEmpty(Guid.NewGuid(), "guid");
        }
    }
}